package com.itheima.filter;


import javax.servlet.*;
import java.io.IOException;

//此注解用来标注此类是一个filter过滤器,其中的属性表示要拦截什么请求
//@WebFilter(urlPatterns = "/*")
public class DemoFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("初始化filter");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("拦截了请求--放行前");
        //放行
        filterChain.doFilter(servletRequest,servletResponse);
        System.out.println("放行后");
    }

    @Override
    public void destroy() {
        System.out.println("销毁filter");
    }
}
